import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    signInfo:null,
    factoryId:null,
    loginInfo:null,
    QRCode:null,
    printList:[],
  },
  getters:{
    getSignInfo(state){
      return state.signInfo;
    },
    getFactoryId(state){
      return state.factoryId;
    },
    getLoginInfo(state){
      return state.loginInfo;
    },
    getQRCode(state){
      return state.QRCode;
    },

    getPrintList(state){
      return state.printList;
    },
    getPrinterByName:(state) => (name) =>{
      return state.printList.filter(item =>item.name==name)
    }
    
  },
  mutations: {
    setSignInfo(state,paylod){
      state.signInfo=paylod;
    },
    setFactoryId(state,id){
      state.factoryId=id;
    },
    setLoginInfo(state,id){
      state.loginInfo=id;
    },
    setQRCode(state,id){
      state.QRCode=id;
    },

    setPrintList(state,paylod){
      state.printList=paylod;
    }
  },
  actions: {
  },
  modules: {
  }
})
